package com.liao.note.service.impl;

import com.liao.note.dao.CategoryDao;
import com.liao.note.dao.NoteDao;
import com.liao.note.domain.Category;
import com.liao.note.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryDao categoryDao;
    @Autowired
    private NoteDao noteDao;

    @Override
    public ArrayList<Category> queryByUserId(Integer userId) {
        return categoryDao.queryByUserId(userId);
    }

    @Override
    public int insert(Category category) {
        int insert = categoryDao.insert(category);
        return insert;
    }

    @Override
    public int update(Category category) {
        return categoryDao.update(category);
    }

    @Override
    public int deleteById(Integer id) {
        int j = noteDao.deleteByCategoryId(id);
        int i = categoryDao.deleteById(id);
        return i;
    }
}
